<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set value="${pageContext.request.contextPath }" var="basePath"></c:set>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>DCMS</title>
    <link rel="stylesheet" href="${basePath}/static/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${basePath}/static/plugins/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="${basePath}/static/build/css/app.css" media="all">
    <link rel="stylesheet" href="${basePath}/static/build/css/themes/light.css" media="all" id="skin" kit-skin />
    <link rel="stylesheet" href="${basePath}/static/plugins/contextmenu/jquery.contextmenu.css"/>
    <style>
    	.layui-nav .layui-badge, .layui-nav .layui-badge-dot
    	{
    		top: 45%;
    	}
    </style>
</head>

<body class="kit-theme">
    <div class="layui-layout layui-layout-admin kit-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">DCMS ADMIN</div>
            <div class="layui-logo kit-logo-mobile">D</div>
            <ul class="layui-nav layui-layout-left kit-nav">
                <li class="layui-nav-item"><a href="javascript:;">控制台</a></li>
                <li class="layui-nav-item">
                    <a href="javascript:;">其它系统</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">邮件管理</a></dd>
                        <dd><a href="javascript:;">消息管理</a></dd>
                        <dd><a href="javascript:;">授权管理</a></dd>
                    </dl>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right kit-nav">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <i class="layui-icon">&#xe63f;</i> 皮肤
                    </a>
                    <dl class="layui-nav-child skin">
                        <dd><a href="javascript:;" data-skin="default" style="color:#393D49;"><i class="layui-icon">&#xe658;</i> 默认</a></dd>
                        <dd><a href="javascript:;" data-skin="light" style="color:#EEEEF2"><i class="layui-icon">&#xe658;</i> 亮灰色</a></dd>
                        <dd><a href="javascript:;" data-skin="green" style="color:#00a65a;"><i class="layui-icon">&#xe658;</i> 原谅绿</a></dd>
                        <dd><a href="javascript:;" data-skin="blue" style="color:#293955"><i class="layui-icon">&#xe658;</i> 深蓝色</a></dd>
                        <dd><a href="javascript:;" data-skin="blue.1" style="color:#00c0ef;"><i class="layui-icon">&#xe658;</i> 天空蓝</a></dd>
                        <dd><a href="javascript:;" data-skin="red" style="color:#dd4b39;"><i class="layui-icon">&#xe658;</i> 枫叶红</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img src="http://m.zhengjinfan.cn/images/0.jpg" class="layui-nav-img"> Van
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" kit-target data-options="{url:'basic.html',icon:'&#xe658;',title:'基本资料',id:'966'}"><span>基本资料</span></a></dd>
                        <dd><a href="javascript:;">安全设置</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="login.html"><i class="fa fa-sign-out" aria-hidden="true"></i> 注销</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black kit-side">
            <div class="layui-side-scroll">
                <div class="kit-side-fold"><i class="fa fa-navicon" aria-hidden="true"></i></div>
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="kitNavbar" kit-navbar lay-accordion>

                </ul>
            </div>
        </div>
        <div class="layui-body" id="container">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">加载中,请稍等...</div>
        </div>

        <div class="layui-footer">
            DCMS 版权所有
        </div>
    </div>
    <script src="<%=basePath %>static/plugins/layui/layui.js"></script>
    <script src="<%=basePath %>static/plugins/jq/jquery-2.2.4.min.js"></script>
    <script src="<%=basePath %>static/plugins/contextmenu/jquery.contextmenu.js"></script>
    <script src="<%=basePath %>static/build/js/common.js"></script>

<script>

    $(function () {


        layui.config({
            base: basePath() + 'static/build/js/',
            dir: basePath() + 'static/plugins/layui/'
        }).use(['app'], function() {
            var app = layui.app;

            //主入口
            app.set({
                type: 'iframe',
                main: 'path/main'
            }).init();
        });


        layui.use(['element', 'tab'], function () {
            var element = layui.element,
                tab = layui.tab;

            //双击关闭
            $('body').on('dblclick', '.layui-tab-title li', function(e){
                var layid = $(this).attr("lay-id");
                if (layid != '-1'){
                    tab.close(layid);
                }
            })

            //禁止文字选中
            $('body').on('selectstart', '.layui-tab-title li', function(e){
                return false;
            });

            //右键菜单
            $('body').on('mousedown', '.layui-tab-title li', function(e){
                var layid = $(this).attr("lay-id");
                if(e.button == 2){ //右键
                    $(this).contextPopup({
                        title: '',
                        items: [
                            {
                                label:'关闭',
                                icon:'fa-times',
                                action:function() {
                                    if (layid != '-1'){
                                        tab.close(layid);
                                    }
                                }
                            },
                            {
                                label:'关闭其他页面',
                                icon:'',
                                action:function() {
                                    $('.layui-tab-title>li').each(function(){
                                        var id = $(this).attr("lay-id");
                                        if(id!=layid && id != '-1'){
                                            tab.close(id);
                                        }
                                    })
                                }
                            },
                            {
                                label:'关闭左侧的所有页面',
                                icon:'',
                                action:function() {
                                    var ids=[];
                                    $('.layui-tab-title>li').each(function(){
                                        var id = $(this).attr("lay-id");
                                        if(id!=layid && id != '-1'){
                                            ids.push(id);
                                        }else if(id==layid){
                                            return false;
                                        }
                                    })

                                    if(ids!=null){
                                        for(var i=0;i<ids.length;i++){
                                            tab.close(ids[i]);
                                        }
                                    }

                                }
                            },
                            {
                                label:'关闭右侧的所有页面',
                                icon:'',
                                action:function() {
                                    var ids=[];
                                    var flag=false;
                                    $('.layui-tab-title>li').each(function(i){
                                        var id = $(this).attr("lay-id");
                                        if(id!=layid && id != '-1'){
                                            if(flag){
                                                ids.push(id);
                                            }
                                        }else if(id==layid){
                                            flag=true;
                                        }
                                    });
                                    if(ids!=null){
                                        for(var i=0;i<ids.length;i++){
                                            tab.close(ids[i]);
                                        }
                                    }

                                }
                            },
                            {
                                label:'关闭所有页面',
                                icon:'',
                                action:function() {
                                    $('.layui-tab-title>li').each(function(){
                                        var id = $(this).attr("lay-id");
                                        if (id != '-1'){
                                            tab.close(id);
                                        }
                                    })
                                }
                            },
                            null,
                            {
                                label:'刷新',
                                icon:'fa-refresh',
                                action:function() {
                                    var iframe = $(".layui-tab-item[lay-item-id='"+layid+"'] iframe");
                                    iframe.attr('src', iframe.attr('src'));
                                }
                            },
                            {
                                label:'刷新所有页面',
                                icon:'',
                                action:function() {
                                    $("iframe").each(function(){
                                        $(this).attr('src', $(this).attr('src'));
                                    })
                                }
                            },
                        ]
                    });
                }
            });

        });

    })

</script>
</body>

</html>